﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using imaginecup.util;
using Microsoft.Xna.Framework.Graphics;
using Imaginecup.util.resourceMan;
using Imaginecup.sprite;
using Imaginecup.sprite.changeSourceSize;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Imaginecup.gameState.scroll;

namespace Imaginecup.gameState.intro
{
    public class ScrollMan:  ISourceInfoClass
    {
        private ISprite m_ScrollSprite;
        private IScrollProcess m_ScrollProcess;
        private bool m_bScroll;

        public ScrollMan()
        {
            m_bScroll = false;
        }

       
        /************************************************************************/
        /* 리소스해제                                                                     */
        /************************************************************************/
        public void Release()
        {
            m_ScrollSprite.Release();

        }
        public void SetScrollProcess(IScrollProcess scrollProcess)
        {
            m_ScrollProcess = scrollProcess;
        }
        public void SetSprite(ISprite sprite)
        {
            m_ScrollSprite = sprite;
        }


        public void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            if( m_bScroll )
                m_ScrollProcess.Scroll(gameTime); 
        } 

        public void Draw(SpriteBatch sb)
        {
            m_ScrollSprite.Draw(sb, new EntityInfo(0, 0, 800, 480));
        }

        public EntityInfo GetSourceInfo()
        {
            return new EntityInfo(m_ScrollProcess.GetCurrentStartPos(), new Vector2(800, 480));
        }


        public void StopScroll()
        {
            m_bScroll = false;
        }

        public void StartScroll()
        {
            m_bScroll = true;
        }

        public Vector2 GetCurrentStartPos()
        {
            return m_ScrollProcess.GetCurrentStartPos();
        }

        public bool IsScrollEnd()
        {
            return m_ScrollProcess.IsScrollEnd();
        }
    }
}
